/**
 * Created with IntelliJ IDEA.
 * Description: 特殊日期
 * User: DELL
 * Date: 2024-03-15
 * Time: 22:02
 */
public class Demo1 {
    public static void main(String[] args) {
        int count = 0;
        int[] temp = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        for (int year = 1900; year < 9999; year++) {
            for (int month = 1; month <= 12; month++) {
                for (int day = 1; day <= temp[month]; day++) {
                    if (judge(year, month, day)) {
                        count++;
                    }
                }
                if (month == 2 && isLeapYear(year)) {
                    if (judge(year, month, 29)) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }

    public static boolean isLeapYear(int year) {
        return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
    }

    public static boolean judge(int year, int month, int day) {
        int count1 = year % 10 + year / 10 % 10 + year / 100 % 10 + year / 1000 % 10;
        return count1 == (month % 10 + month / 10 % 10 + day % 10 + day / 10 % 10);
    }
}
